<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('项目信息变更')" />
    <th:block th:include="include :: jsonview-css" />
    <th:block th:include="includeProject :: project-css" />
</head>
<body class="gray-bg">
    <div class="wrapper wrapper-content">
        <div class="col-sm-12">
            <div class="row">
                <div class="col-sm-12">
                    <th:block th:include="includeProject :: projectInfo" />
                </div>
                <div class="col-sm-12" th:if="${type} == 'invest'">
                    <div class="ibox float-e-margins">
                        <div class="ibox-title">
                            <h5 style="font: bold">投资建设资金情况</h5>
                            <div class="ibox-tools">
                                <a class="collapse-link">
                                    <i class="fa fa-chevron-up"></i>
                                </a>
                            </div>
                        </div>
                        <div class="ibox-content" id="ibox-content">
                            <div class="row">
                                <div class="col-sm-12">
                                    <form class="form form-horizontal m-t"  id="form-edit">
                                        <input type="hidden" id="projectId" name="projectId" th:value="${project.projectId}">

                                        <div class="col-md-6">
                                            <div class="info-label control-label is-required">总投资：</div>
                                            <div class="info-value">
                                                <div class="input-group m-b col-md-5"><span class="input-group-addon">&yen;</span>
                                                    <input name="totalInvest" placeholder="请输入" class="form-control" type="text" maxlength="10" th:value="${#numbers.formatDecimal(project.totalInvest,1,2)}">
                                                    <span class="input-group-addon">亿元</span>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-md-6">
                                            <div class="info-label control-label">已累计完成投资：</div>
                                            <div class="info-value">
                                                <div class="input-group m-b col-md-5"><span class="input-group-addon">&yen;</span>
                                                    <input name="doneInvest" placeholder="请输入" class="form-control" type="text" maxlength="10" th:value="${#numbers.formatDecimal(project.doneInvest,1,2)}">
                                                    <span class="input-group-addon">亿元</span>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-md-6">
                                            <div class="info-label control-label">实际到位资金：</div>
                                            <div class="info-value">
                                                <div class="input-group m-b col-md-5"><span class="input-group-addon">&yen;</span>
                                                    <input name="actualInvest" placeholder="请输入" class="form-control" type="text" maxlength="10" th:value="${#numbers.formatDecimal(project.actualInvest,1,2)}">
                                                    <span class="input-group-addon">亿元</span>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-md-6">
                                            <div class="info-label control-label is-required">2022年计划投资：</div>
                                            <div class="info-value">
                                                <div class="input-group m-b col-md-5"><span class="input-group-addon">&yen;</span>
                                                    <input name="planInvest" placeholder="请输入" class="form-control" type="text" maxlength="10" th:value="${#numbers.formatDecimal(project.planInvest,1,2)}">
                                                    <span class="input-group-addon">亿元</span>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-md-6">
                                            <div class="info-label control-label">资金需求：</div>
                                            <div class="info-value">
                                                <div class="input-group m-b col-md-5"><span class="input-group-addon">&yen;</span>
                                                    <input name="fundDemand" placeholder="请输入" class="form-control" type="text" maxlength="10" th:value="${#numbers.formatDecimal(project.fundDemand,1,2)}">
                                                    <span class="input-group-addon">亿元</span>
                                                </div>
                                            </div>
                                        </div>
                                    </form>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-sm-12" th:if="${project.isSixDone} == 0 and ${type} == 'sixDone'">
                    <form class="form form-horizontal m-t"  id="form-edit">
                        <input type="hidden" id="projectId" name="projectId" th:value="${project.projectId}">
                        <!-- 定措施 -->
                        <div class="row">
                            <div class="col-sm-12">
                                <div class="ibox float-e-margins">
                                    <div class="ibox-title">
                                        <h5 style="font: bold">定措施</h5>
                                        <div class="ibox-tools">
                                            <a class="collapse-link">
                                                <i class="fa fa-chevron-up"></i>
                                            </a>
                                        </div>
                                    </div>
                                    <div class="ibox-content">
                                        <div class="row">
                                            <div class="col-sm-12">
                                                <div class="col-sm-9">
                                                    <label class="col-sm-12 control-label is-required" style="font-weight: bold;text-align: left;padding-left: 0px;">推进措施：</label>
                                                    <textarea rows="3" cols="2000"  class="form-control" name="projectMeasure" th:field="${project.projectMeasure}" placeholder="请输入" required></textarea>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <!-- 定专班 -->
                        <div class="row">
                            <div class="col-sm-12">
                                <div class="ibox float-e-margins">
                                    <div class="ibox-title">
                                        <h5 style="font: bold">定专班</h5>
                                        <div class="ibox-tools">
                                            <a class="collapse-link">
                                                <i class="fa fa-chevron-up"></i>
                                            </a>
                                        </div>
                                    </div>
                                    <div class="ibox-content">
                                        <div class="row">
                                            <div class="col-sm-12">
                                                <div class="col-sm-9">
                                                    <label class="col-sm-12 control-label is-required" style="font-weight: bold;text-align: left;padding-left: 0px;">项目推进专班组建情况：</label>
                                                    <textarea rows="3" cols="2000"  class="form-control" name="projectDirector" th:field="${project.projectDirector}" placeholder="请输入" required></textarea>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <!-- 定责任 -->
                        <div class="row">
                            <div class="col-sm-12">
                                <div class="ibox float-e-margins">
                                    <div class="ibox-title">
                                        <h5 style="font: bold">定责任</h5>
                                        <div class="ibox-tools">
                                            <a class="collapse-link">
                                                <i class="fa fa-chevron-up"></i>
                                            </a>
                                        </div>
                                    </div>
                                    <div class="ibox-content">
                                        <div class="row">
                                            <div class="col-sm-12">
                                                <div class="col-sm-6">
                                                    <label class="col-sm-12 control-label is-required" style="font-weight: bold;text-align: left;padding-left: 0px;">项目责任人：</label>
                                                    <div>
                                                        <input name="responseName" th:value="${project.responseName}" placeholder="请输入项目责任人" class="form-control" type="text" required>
                                                    </div>
                                                </div>
                                                <div class="col-sm-3">
                                                    <label class="col-sm-12 control-label is-required" style="font-weight: bold;text-align: left;padding-left: 0px;">手机号码：</label>
                                                    <div>
                                                        <input name="responsePhone" th:value="${project.responsePhone}" class="form-control" placeholder="请输入手机号码" type="text" maxlength="11"  required>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <!-- 定考核 -->
                        <div class="row">
                            <div class="col-sm-12">
                                <div class="ibox float-e-margins">
                                    <div class="ibox-title">
                                        <h5 style="font: bold">定考核</h5>
                                        <div class="ibox-tools">
                                            <a class="collapse-link">
                                                <i class="fa fa-chevron-up"></i>
                                            </a>
                                        </div>
                                    </div>
                                    <div class="ibox-content">
                                        <div class="row">
                                            <div class="col-sm-12">
                                                <div class="col-sm-3">
                                                    <label class="col-sm-12 control-label is-required" style="font-weight: bold;text-align: left;padding-left: 0px;">2022年第一季度拟完成投资：</label>
                                                    <div class="input-group m-b col-md-12"><span class="input-group-addon">&yen;</span>
                                                        <input name="planInvestQuarter1" th:value="${#numbers.formatDecimal(project.planInvestQuarter1,1,2)}" placeholder="请输入" class="form-control" type="text" required>
                                                        <span class="input-group-addon">亿元</span>
                                                    </div>
                                                </div>
                                                <div class="col-sm-3">
                                                    <label class="col-sm-12 control-label is-required" style="font-weight: bold;text-align: left;padding-left: 0px;">2022年第二季度拟完成投资：</label>
                                                    <div class="input-group m-b col-md-12"><span class="input-group-addon">&yen;</span>
                                                        <input name="planInvestQuarter2" th:value="${#numbers.formatDecimal(project.planInvestQuarter2,1,2)}" placeholder="请输入" class="form-control" type="text" required>
                                                        <span class="input-group-addon">亿元</span>
                                                    </div>
                                                </div>
                                                <div class="col-sm-3">
                                                    <label class="col-sm-12 control-label is-required" style="font-weight: bold;text-align: left;padding-left: 0px;">2022年第三季度拟完成投资：</label>
                                                    <div class="input-group m-b col-md-12"><span class="input-group-addon">&yen;</span>
                                                        <input name="planInvestQuarter3" th:value="${#numbers.formatDecimal(project.planInvestQuarter3,1,2)}" placeholder="请输入" class="form-control" type="text" required>
                                                        <span class="input-group-addon">亿元</span>
                                                    </div>
                                                </div>
                                                <div class="col-sm-3">
                                                    <label class="col-sm-12 control-label is-required" style="font-weight: bold;text-align: left;padding-left: 0px;">2022年第四季度拟完成投资：</label>
                                                    <div class="input-group m-b col-md-12"><span class="input-group-addon">&yen;</span>
                                                        <input name="planInvestQuarter4" th:value="${#numbers.formatDecimal(project.planInvestQuarter4,1,2)}" placeholder="请输入" class="form-control" type="text" required>
                                                        <span class="input-group-addon">亿元</span>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
    <div class="ui-layout-center" th:if="${type} == 'owner'">
        <div class="container-div">
            <div class="row">
                <div class="col-sm-12 search-collapse">
                    <form id="user-form">
                        <div class="select-list">
                            <ul>
                                <li>
                                    登录名称：<input type="text" name="loginName"/>
                                </li>
                                <li>
                                    用户名称：<input type="text" name="userName"/>
                                </li>
                                <li>
                                    <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                    <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                                </li>
                            </ul>
                        </div>
                    </form>
                </div>
                <div class="btn-group-sm" id="toolbar" role="group">
                    <a class="btn btn-primary single disabled" onclick="saveProject()">
                        <i class="fa fa-edit"></i> 变更所属
                    </a>
                </div>
                <div class="col-sm-12 select-table table-striped">
                    <table id="bootstrap-table"></table>
                </div>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-sm-offset-5 col-sm-10">
            <button type="button" class="btn btn-sm" onclick="closeItem()"><i class="fa fa-reply-all"></i>返 回</button>
            <button type="button" class="btn btn-sm btn-primary" onclick="saveProject()" th:if="${type} != 'owner'"><i class="fa fa-check"></i>保 存</button>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <!--<th:block th:include="include :: select2-js" />-->
    <th:block th:include="includeProject :: project-js" />
    <script th:inline="javascript" th:if="${type} != 'owner'">
        /** 保存项目 */
        function saveProject(){
            // 1、声明基础校验规则 validateRules
            var validateResult = $("#form-edit").validate({
                rules: {
                    totalInvest: {
                        required: true,
                        number: true,
                        gt: 0
                    },
                    /*doneInvest: {
                        required: true,
                        number: true,
                        gt: 0
                    },
                    actualInvest: {
                        required: true,
                        number: true,
                        gt: 0
                    },*/
                    planInvest: {
                        required: true,
                        number: true,
                        gt: 0
                    },
                    planInvestQuarter1: {number: true, gt: 0},
                    planInvestQuarter2: {number: true, gt: 0},
                    planInvestQuarter3: {number: true, gt: 0},
                    planInvestQuarter4: {number: true, gt: 0},
                    responsePhone: {isPhone: true}
                }
            }).form();
            // 2、校验表单
            if(!validateResult){
                return;
            }

            var data = {};
            $('.form').each(function (index, form){
                // 这里可以使用$.common.formToJSON(formId);  需要在form上加id
                $.each($(form).serializeArray(), function(i, field) {
                    if(data[field.name]) {
                        data[field.name] += ("," + field.value);
                    } else {
                        data[field.name] = field.value;
                    }
                });
            });

            $.ajax({
                cache : true,
                type : "POST",
                url : ctx + "manage/project/editOther",
                data : data,
                async : false,
                error : function(request) {
                    $.modal.alertError("系统错误");
                },
                success : function(data) {
                    $.operate.successTabCallback({'code':'0'});
                }
            });
            // $.operate.saveTab(ctx + "manage/project/add", data);
        }


    </script>
    <script th:inline="javascript" th:if="${type} != 'basic'">
        // 合起项目基础信息
        $('#_projectInfo_link').trigger('click');
    </script>
    <script th:inline="javascript" th:if="${type} == 'owner'">
        var prefix = ctx + "system/user";
        $(function() {
            var options = {
                url: prefix + "/list",
                sortName: "createTime",
                sortOrder: "desc",
                modalName: "用户",
                columns: [{
                    checkbox: true
                },
                    {
                        field: 'loginName',
                        title: '登录名称'
                    },
                    {
                        field: 'userName',
                        title: '用户名称'
                    },
                    {
                        field: 'dept.deptName',
                        title: '部门'
                    },
                    {
                        field: 'createTime',
                        title: '创建时间'
                    }]
            };
            $.table.init(options);
        });

        function saveProject(){
            // 获取选择的用户
            table.set();

            var row = $("#" + table.options.id).bootstrapTable('getSelections')[0];
            if ($.common.isEmpty(row)) {
                $.modal.alertWarning("请选择一条记录");
                return;
            }

            var data = {};
            data['projectId'] = $('#projectId').val();
            data['createBy'] = row.loginName;

            $.modal.confirm("确定修改该项目的所属信息吗？", function() {
                $.ajax({
                    cache : true,
                    type : "POST",
                    url : ctx + "manage/project/editOther",
                    data : data,
                    async : false,
                    error : function(request) {
                        $.modal.alertError("系统错误");
                    },
                    success : function(data) {
                        $.operate.successTabCallback({'code':'0'});
                    }
                });
            });
        }
    </script>
</body>
</html>